package com.wdb007.venus.wss.bootstrap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ImportResource;

import com.wdb007.venus.wss.sysPojo.ServerList;

@SpringBootApplication
@ImportResource({ "classpath:wss.xml" })
public class Application {

	private static Logger log = LoggerFactory.getLogger(Application.class);
	
	
	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		new SpringApplicationBuilder().sources(Application.class).web(false)
		.run(args);
		long end = System.currentTimeMillis();

		log.info("venus-quartz启动成功,耗时：{} ms", end - start);

		IServer iServer = (IServer) ServerList.getCtx().getBean("basicServer");
		iServer.start(0);

	}
//	static {
//		// 先加载spring
//		log.info("准备载入spring...");
//		ServerList.setCtx(new ClassPathXmlApplicationContext("wss.xml"));
//		log.info("载入spring 完毕...");
//	}

//	public static void main(String[] args) throws Exception {
//		Integer serverNum = ServerList.getServerNum();
//		
//		for(int serverNo=0;serverNo<serverNum;serverNo++){
//			new Thread(new Application().new ServerThread(serverNo)).start();
//			log.info("单次server开始启动...");
//		}
//	}
//	
//	/**
//	 * 
//	* 类说明
//	* @Description: 内部类，并发启动server用
//	* @author  fengjun
//	* @date 2015年11月5日 下午3:33:21
//	* @version V1.0
//	 */
//	class ServerThread implements Runnable{
//		int serverNo=0;
//		
//		public ServerThread(int serverNo){
//			this.serverNo = serverNo;
//		}
//		
//		@Override
//		public void run() {
//			try {
//				IServer iServer = (IServer) ServerList.getCtx().getBean("basicServer");
//				iServer.start(serverNo);
//			} catch (Exception e) {
//				log.error("error when startup server thread to create new server["+ serverNo+"]", e);
//			}
//		}
//	}
}
